// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode fieldsfirst 

package net.minecraft.util;

import java.awt.*;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.*;

public class OutputConsole extends JFrame
{
	private static final long serialVersionUID = 1L;
    int threadsUsing;
    private JScrollPane jScrollPane1;
    private JTextArea jTextArea1;

    public OutputConsole()
    {
        threadsUsing = 0;
        initComponents();
        jScrollPane1.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            public void adjustmentValueChanged(AdjustmentEvent adjustmentevent)
            {
                adjustmentevent.getAdjustable().setValue(adjustmentevent.getAdjustable().getMaximum());
            }

        }
);
        pack();
        setVisible(true);
    }

    private void initComponents()
    {
        jScrollPane1 = new JScrollPane();
        jTextArea1 = new JTextArea();
        setDefaultCloseOperation(2);
        setTitle("Error Console");
        jScrollPane1.setAutoscrolls(true);
        jScrollPane1.setColumnHeaderView(null);
        jScrollPane1.setCursor(new Cursor(0));
        jScrollPane1.setDebugGraphicsOptions(-1);
        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setRows(5);
        jTextArea1.setDropMode(DropMode.INSERT);
        jScrollPane1.setViewportView(jTextArea1);
        GroupLayout grouplayout = new GroupLayout(getContentPane());
        getContentPane().setLayout(grouplayout);
        grouplayout.setHorizontalGroup(grouplayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(grouplayout.createSequentialGroup().addContainerGap().addComponent(jScrollPane1, -1, 636, 32767).addContainerGap()));
        grouplayout.setVerticalGroup(grouplayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(grouplayout.createSequentialGroup().addContainerGap().addComponent(jScrollPane1, -1, 227, 32767).addContainerGap()));
        pack();
    }

    public static void main(String args[])
    {
        EventQueue.invokeLater(new Runnable() {

            public void run()
            {
                (new OutputConsole()).setVisible(true);
            }

        }
);
    }

    public void appendText(String s)
    {
        jTextArea1.append(s);
        jTextArea1.selectAll();
        if(threadsUsing <= 0)
        {
            waitToDispose();
        }
    }

    public void acquire()
    {
        threadsUsing++;
    }

    public void release()
    {
        threadsUsing--;
        if(threadsUsing <= 0)
        {
            waitToDispose();
        }
    }

    public void waitToDispose()
    {
        jTextArea1.append("\n\nThreads have Stopped... closing this window in 15 Seconds...\nIf you want to copy this, do it NOW!");
        try
        {
            Thread.sleep(15000L);
        }
        catch(InterruptedException interruptedexception) { }
        finally
        {
            dispose();
        }
    }
}
